<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
	<style>
		#InfoHit{	color:#00F;	font-weight:bold;}
		label{	color:#00F; 	line-height:21px; 	font-weight:bold; 	height:21px; 	vertical-align:middle;	font-size:12px;}
		.s-1, .s1{color:red}
	</style>
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <form enctype="multipart/form-data"  method="post" id="frm">
    <input type="hidden" name="Keywords" id="Keywords" value="{$Keywords}" />
    <input type="hidden" name="NowPage" id="NowPage" value="{$NowPage}" />
        <div class="table">
        <div class="toolbars">
            <li class="toolbar"><a id="btnBack" href="{$Url}card" title="返回">返回</a></li>   
            <li class="toolbar"><a id="btnSaveAll" href="{$Url}AddCoupon"  title="添加优惠卷" target="_self">添加优惠卷</a></li>
            <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
            <li class="toolbar"><a id="del" onclick="BatchDel()" title="批量删除">删除</a></li>
            <li class="toolbar"><a id="sortall" onclick="BatchSort()" title="批量排序">排序</a></li>
            <li class="toolbar toolbarform">
                <label>优惠卷名称</label>
                <input type="text" class='textinput' name="Keywords" style="width:150px" value="{$Keywords}" id="Keywords"/>
                <input id="btnSeek" class="btnToolbarForm" type="submit" value="查询" onclick="Search()">
            </li>
        </div>
        <table class="datatable" id="datatable">
            <tr>
                <th width="35px"  nowrap="nowrap">选中</th>
                <th width="55px" nowrap="nowrap">优惠卷ID</th>
                <th width="45px" nowrap="nowrap">排序</th>
                <th  width="180px">优惠卷名称</th>
                <th width="200px" >有效期</th>
                
                <th width="85px">被使用次数</th>
                <th width="85px">最多使用次数</th>
                <th>使用说明</th>
                <th width="80px" >属性</th>
                <th width="150px">操作</th>
            </tr>  
            <notempty name="Coupon">                
                <volist name="Coupon" id="g">
                    <tr>
                        <td><input class="checkrow" type="checkbox" name="CouponID[]" value="{$g.CouponID}" /></td>
                        <td>{$g.CouponID}</td>
                        <td><input type="text" class='textinput' onclick="this.select()" style="width:45px" name="CouponOrder[]" value="{$g.CouponOrder}" />
                        <input type="hidden" class='textinput' style="width:50px" name="CouponOrderID[]" value="{$g.CouponID}" /></td>
                        <td><b  class="s{$g.Flag}">{$g.CouponName}</b><br /></td>
                        <td><b>开始时间：</b>{$g.StartTime}<br />
                        <b>结束时间：</b>{$g.EndTime}
                        </td>
                        
                        <td><b style="color:#F30">{$g.CouponUsed}</b><br /><a onclick="CouponMember({$g.CouponID})">查看使用会员<a></td>
                        <td style="color:#0000FF">{$g.CouponNumber}</td>
                        <td style="text-align:left">{$g.Remark}</td>
                        <td>
                            <b style="color:red">
                                <switch name="g.Flag">
                                    <case value="-1">未开始</case>
                                    <case value="0"></case>
                                    <case value="1">已过期</case>
                                </switch>
                            </b>&nbsp;&nbsp;
                            <eq name="g.IsEnable" value="1">
                                    <span style="color:#000;cursor:pointer;"  onclick="toggleStatus(this,{$g.CouponID},'wx_coupon')">启用</span>
                            <else/>
                                    <span style="color:#F00;cursor:pointer;"  onclick="toggleStatus(this,{$g.CouponID},'wx_coupon')">禁用</span>
                            </eq>
                        </td>
                        <td class="operator">
                            <a style="float:left" onclick="Edit({$g.CouponID})" id="btnEdit">修改</a>
                            <div class="btn-sep"></div>
                            <a style="float:left" onclick="Del({$g.CouponID})" class="btnDel">删除</a>
                        </td>
                    </tr>
                </volist>
            <else/>
                <tr><td colspan="10" id="NoData">{$Think.lang.NoDataTip}</td></tr>
            </notempty>                                
        </table>
         <div class="tfoot">
              <div class="page"><span class="pagesize">每页<span class="pz">{$AdminPageSize}</span>条</span>{$Page}</div>
         </div>
    </div>
</form>
</div>
</body>
</html>
<script type="text/javascript">
//排序
function BatchSort(){
	$.confirm("{$Think.lang.SortTip}", function () {
		$('#frm').attr("action", "__URL__/batchSortCoupon");
		$('#frm').submit();
	}, function () {
		return true;
	}); 
}	

//查询
function Search(){
	$('#frm').attr("action", "__URL__/coupon");
	$('#frm').submit();
	return true;
}	

function Edit(id){
	url = "{$Url}modifyCoupon/CouponID/"+id;
	location.href = url;
}

function Del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		url = "{$Url}delCoupon/CouponID/"+id+"/NowPage/{$NowPage}/Keywords/{$Keywords}";
		location.href = url;
	}, function () {
		return true;
	});
}

function BatchDel(){
	//var arrChk = $("input[name='InfoID[]'][checked]"); //在高速浏览器长度总是返回0
	var arrChk = $("input[name='CouponID[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		$('#frm').attr("action", "__URL__/DelCoupon");
		$('#frm').submit();
	}, function () {
		return true;
	});
}

//查看优惠卷记录
function CouponMember(id){
	var url = "{$Url}couponMember/CouponID/"+id;
	location.href = url;
}

//提示信息
$(document).ready(function(){
	//选中操作
	$("#Keywords").focus();
});
</script>